package com.traffic.api.sms;


import org.springframework.stereotype.Component;

@Component
public class SMSService {
	
	/*//科讯请求参数
	public static final String KEXUN_ACCOUNT = PropertiesUtil.getProperty("kexun_account");
	public static final String KEXUN_PASSWORD = PropertiesUtil.getProperty("kexun_password");
	public static final String KEXUN_USERID = PropertiesUtil.getProperty("kexun_userid");
	
	@Autowired
	private SmsInfoDao smsInfoDao;
	
	@Autowired
    protected DataFieldMaxValueIncrementer idGenarater;

    public DataFieldMaxValueIncrementer getIdGenarater() {
        return idGenarater;
    }

    public void setIdGenarater(DataFieldMaxValueIncrementer idGenarater) {
        this.idGenarater = idGenarater;
    }
	
	public boolean sendSms(String exoNo,String phone, String content,SmsInfo smsInfo) {
		boolean result;
        try {
            result = true;
            result = sendSMS_KX(phone, content,smsInfo,exoNo);
            
            *//*if("LT".equals(PhoneNumberUtil.getType(phone))){
                result = sendSMS_KX(phone, content,smsInfo,channel.getExtno());
            }else if("DX".equals(PhoneNumberUtil.getType(phone))){ 
            	result = sendSMS_KX(phone, content,smsInfo,channel.getExtno());
            }else if("YD".equals(PhoneNumberUtil.getType(phone))){
            	result = sendSMS_KX(phone, content,smsInfo,channel.getExtno());
            }else{
            	//暂时都走这个地方
            	result = sendSMS_KX(phone, content,smsInfo,channel.getExtno());
            } *//*
        } catch (Exception e) {
            result = false;
            e.printStackTrace();
        }
		return result;
	}
	
	
	
	*//**
     * 科迅短信  主力发送渠道
     * *//*
    private boolean sendSMS_KX(String phone, String content,SmsInfo smsInfo,String extno) {
        KXTSmsSDK kxtsms = new KXTSmsSDK();
        kxtsms.init("120.76.25.160", 7788, KEXUN_ACCOUNT, KEXUN_PASSWORD,Integer.valueOf(KEXUN_USERID));
        try {
            content = URLEncoder.encode(content,"UTF-8");//URL编码 UTF-8方式
        } catch (Exception e) {
            
        }
        String result = kxtsms.send(phone,content,extno);
        System.out.println(result);
        
        if(!StringUtil.isNull(result)){
            try {
                Document document = DocumentHelper.parseText(result);
                Element root = document.getRootElement();
                
				List<Element> childElements = root.elements();
                String returnstatus  = "";
                String taskID = "";
                for (Element child : childElements) {
                    if(child.getName().equals("returnstatus")){
                        returnstatus = child.getTextTrim();
                    }else if(child.getName().equals("taskID")){
                        taskID = child.getTextTrim();
                    }
                } 
                smsInfo.setTaskId(taskID);
                smsInfo.setStatus("Success".equals(returnstatus)?"0":"1");
                
                System.out.println("-------------------");
                
                smsInfoDao.save(smsInfo);
                
                
                if("Success".equals(returnstatus)){
                    return true;
                }else{
                    return false;
                }  
            } catch (DocumentException e) {
                e.printStackTrace();
                return false;
            }  
        }
        
        return false;
    }
	
	public static void main(String[] args) {
		KXTSmsSDK kxtsms = new KXTSmsSDK();ybtest
		kxtsms.init("120.76.25.160", 7788, KEXUN_ACCOUNT, KEXUN_PASSWORD,Integer.valueOf(KEXUN_USERID));
		String content = "测试数据【的士预约】";
		try {
			content = URLEncoder.encode(content,"UTF-8");//URL编码 UTF-8方式
		} catch (Exception e) {

		}
		String result = kxtsms.send("15871334133",content,"712053");
		System.out.println(result);
	}*/
}
